package com.cloudy.security;

import java.util.ResourceBundle;
import java.util.logging.Logger;

public class AccessIdentifiers {
	private static String accessKeyID;
	private static String secretAccessKey;
	private static Logger logger = Logger.getLogger(AccessIdentifiers.class.getName());
	static{
		initAccessIdentifiersFromFile();
	}
	
	public static void initAccessIdentifiersFromFile(){
		try{
			ResourceBundle bundle = ResourceBundle.getBundle("AWSAccessKey");
			accessKeyID = bundle.getString("accessKeyID");
			secretAccessKey = bundle.getString("secretAccessKey");
		}catch(Exception e){
			logger.info("Couldnt find budle cloudy. Assuming that Access Identifiers will be set through methods.");
		}
	}
	
	
	public static String getAccessKeyID() {
		if (accessKeyID == null)
			throw new RuntimeException("Access Key ID can not be Null! Set with AccessIdentifiers.setAccessKeyID() ");
		return accessKeyID;
	}
	public static void setAccessKeyID(String accessKeyID) {
		AccessIdentifiers.accessKeyID = accessKeyID;
	}
	public static String getSecretAccessKey() {
		if (secretAccessKey == null)
			throw new RuntimeException("Secret Access Key can not be Null! Set with AccessIdentifiers.setSecretAccessKey() ");
		return secretAccessKey;
	}
	public static void setSecretAccessKey(String secretAccessKey) {
		AccessIdentifiers.secretAccessKey = secretAccessKey;
	}
}
